{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>Newtonsoft.Json, 13.0.3</span></li></ul></div></div>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#r \"nuget: Newtonsoft.Json\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "dotnet_interactive": {
     "language": "csharp"
    },
    "polyglot_notebook": {
     "kernelName": "csharp"
    },
    "vscode": {
     "languageId": "polyglot-notebook"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123\r\n"
     ]
    }
   ],
   "source": [
    "using Newtonsoft.Json;\n",
    "using Newtonsoft.Json.Serialization;\n",
    "\n",
    "string _str = \"123\"; \n",
    "var setting = new JsonSerializerSettings\n",
    "{\n",
    "    Formatting = Formatting.Indented,\n",
    "\n",
    "    ContractResolver = new DefaultContractResolver\n",
    "    {\n",
    "        NamingStrategy = new SnakeCaseNamingStrategy()\n",
    "    },\n",
    "    NullValueHandling = NullValueHandling.Ignore,               // 空值是否显示\n",
    "    StringEscapeHandling = StringEscapeHandling.Default,        // 字符串转义处理方式\n",
    "    TypeNameHandling = TypeNameHandling.None,                   // 是否输出类型名称\n",
    "    ObjectCreationHandling = ObjectCreationHandling.Replace     // 对象创建时替换原对象\n",
    "};\n",
    "string json = JsonConvert.SerializeObject(_str, setting);\n",
    "\n",
    "Console.WriteLine(_str);"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".NET (C#)",
   "language": "C#",
   "name": ".net-csharp"
  },
  "language_info": {
   "name": "python"
  },
  "polyglot_notebook": {
   "kernelInfo": {
    "defaultKernelName": "csharp",
    "items": [
     {
      "aliases": [],
      "name": "csharp"
     }
    ]
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
